package Game.screen;
import static org.lwjgl.opengl.GL11.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;

import Game.Cube;

public class TelaEntrada extends Cube{

	public Texture textures;
	public TelaEntrada(float x, float y, float z, String texturePath) {
		super(x, y, z);
		
		try {
			textures = TextureLoader.getTexture("PNG", new FileInputStream(
					texturePath));
		} catch (FileNotFoundException e) {
			System.err.println(e);
		} catch (IOException e) {
			System.err.println(e);
		}

		textures.bind();
	}
	@Override
	public void Render() {
		// TODO Auto-generated method stub
	glBindTexture(GL_TEXTURE_2D, textures.getTextureID());
		
		glPushMatrix();
		{
			glBegin(GL_QUADS);
			{
				//face cara
				glNormal3f(x-w/2, y-h/2, z-d/2);
				glTexCoord2f(1, 1);
				glVertex3d(x-w/2, y-h/2, z-d/2);
				
				glNormal3f(x+w/2, y-h/2, z-d/2);
				glTexCoord2f(0, 1);
				glVertex3d(x+w/2, y-h/2, z-d/2);
				
				glNormal3f(x+w/2, y+h/2, z-d/2);
				glTexCoord2f(0, 0);
				glVertex3d(x+w/2, y+h/2, z-d/2);
				
				glNormal3f(x-w/2, y+h/2, z-d/2);
				glTexCoord2f(1, 0);
				glVertex3d(x-w/2, y+h/2, z-d/2);
				
				
				//face traz
				glNormal3f(x-w/2, y-2/2, z+d/2);
				glTexCoord2f(1, 1);
				glVertex3d(x-w/2, y-2/2, z+d/2);
				
				glNormal3f(x+w/2, y-h/2, z+d/2);
				glTexCoord2f(0, 1);
				glVertex3d(x+w/2, y-h/2, z+d/2);
				
				glNormal3f(x+w/2, y+h/2, z+d/2);
				glTexCoord2f(0, 0);
				glVertex3d(x+w/2, y+h/2, z+d/2);
				
				glNormal3f(x-w/2, y+h/2, z+d/2);
				glTexCoord2f(1, 0);
				glVertex3d(x-w/2, y+h/2, z+d/2);

				//face esquerda
				glNormal3f(x+w/2, y-h/2, z+d/2);
				glTexCoord2f(1, 1);
				glVertex3d(x+w/2, y-h/2, z+d/2);

				glNormal3f(x+w/2, y-h/2, z+d/2);
				glTexCoord2f(0, 1);
				glVertex3d(x+w/2, y-h/2, z+d/2);
				
				glNormal3f(x+w/2, y+h/2, z-d/2);
				glTexCoord2f(0, 0);
				glVertex3d(x+w/2, y+h/2, z-d/2);
				
				glNormal3f(x+w/2, y+h/2, z-d/2);
				glTexCoord2f(1, 0);
				glVertex3d(x+w/2, y+h/2, z-d/2);
			
				
				//face direita
				glNormal3f(x-w/2, y-h/2, z+d/2);
				glTexCoord2f(1, 1);
				glVertex3d(x-w/2, y-h/2, z+d/2);
				
				glNormal3f(x-w/2, y-h/2, z+d/2);
				glTexCoord2f(1, 1);
				glVertex3d(x-w/2, y-h/2, z+d/2);
				
				glNormal3f(x-w/2, y+h/2, z-d/2);
				glTexCoord2f(0, 0);
				glVertex3d(x-w/2, y+h/2, z-d/2);
				
				glNormal3f(x-w/2, y+h/2, z-d/2);
				glTexCoord2f(1, 0);
				glVertex3d(x-w/2, y+h/2, z-d/2);
			}
		}
			glEnd();
		glPopMatrix();
	}

}
